package flyweight.pattern.factory;

import java.util.HashMap;

import flyweight.pattern.shape.Shape;
import flyweight.pattern.shape.impl.CircleShape;

public class ShapeFactory {
    private static final HashMap<String, Shape> map = new HashMap<>();

    public static Shape getCircle(final String color) {
        CircleShape circle = (CircleShape)map.get(color);
        
        if(null==circle) {
            circle = new CircleShape(color);
            map.put(color, circle);
            System.out.println("creating new "+color+"circle ");
        }
        return circle;
    }
}
